//
//  LZMyCouponsTableViewHeaderView.m
//  laziz_Consumer
//
//  Created by xbn_iMac on 2017/1/23.
//  Copyright © 2017年 XBN. All rights reserved.
//

#import "LZMyCouponsTableViewHeaderView.h"
#import "Masonry.h"

@interface LZMyCouponsTableViewHeaderView ()

@property (nonatomic, strong) UILabel *label;

@end

@implementation LZMyCouponsTableViewHeaderView

- (instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithReuseIdentifier:reuseIdentifier];
    if (self) {
        self.backgroundColor = UIColorFromRGB(0xffffff, 1);

        [self configUI];
    }
    return self;
}

#pragma mark - private method

- (void)configUI {
    
    self.label = [[UILabel alloc] init];
    self.label.backgroundColor = [UIColor clearColor];
    self.label.font = [UIFont systemFontOfSize:15];
    self.label.textColor = UIColorFromRGB(0x333333, 1);
    self.label.preferredMaxLayoutWidth = SCREEN_WIDTH - 20;
    self.label.numberOfLines = 0;
    [self addSubview:self.label];
    
    UIView * line = [[UIView alloc] init];
    line.backgroundColor = UIColorFromRGB(0xeeeeee, 1);
    [self addSubview:line];
    
    [self.label makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.mas_centerY);
        make.leading.mas_equalTo(10);
        make.trailing.mas_equalTo(-10);
    }];
    
    [line makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(0);
        make.leading.mas_equalTo(10);
        make.trailing.mas_equalTo(-10);
        make.height.mas_equalTo(0.5);
    }];
}

#pragma mark - public method

- (void)setText:(NSString*)text {
    if (text == nil) {
        text = @"";
    }
    self.label.text = text;
}

- (CGSize)intrinsicContentSize {
    return CGSizeMake(SCREEN_WIDTH, MAX(55, (37+self.label.intrinsicContentSize.height)));
}

@end
